home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / elispman.lha / elispman / elisp-36 (.txt) < prev    next >
GNU Info File  |  1993-05-11  |  50KB  |  777 lines

  1. This is Info file elisp, produced by Makeinfo-1.52 from the input file
  2. elisp.texi.
  3.    This file documents GNU Emacs Lisp.
  4.    This is edition 2.0 of the GNU Emacs Lisp Reference Manual, for
  5. Emacs Version 19.
  6.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  7. Cambridge, MA 02139 USA
  8.    Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20. File: elisp,  Node: GNU Emacs Internals,  Next: Standard Errors,  Prev: Tips,  Up: Top
  21. GNU Emacs Internals
  22. *******************
  23.                                       This chapter describes how the
  24. runnable Emacs executable is dumped with the preloaded Lisp libraries
  25. in it, how storage is allocated, and some internal aspects of GNU Emacs
  26. that may be of interest to C programmers.
  27.                                    * Menu:
  28.                                    
  29.                                    * Building Emacs::      How to preload Lisp libraries into Emacs.
  30.                                    * Pure Storage::        A kludge to make preloaded Lisp functions sharable.
  31.                                    * Garbage Collection::  Reclaiming space for Lisp objects no longer used.
  32.                                    * Object Internals::    Data formats of buffers, windows, processes.
  33.                                    * Writing Emacs Primitives::   Writing C code for Emacs.
  34. File: elisp,  Node: Building Emacs,  Next: Pure Storage,  Prev: GNU Emacs Internals,  Up: GNU Emacs Internals
  35. Building Emacs
  36. ==============
  37.                                       The first step in building Emacs
  38. is to compile the C sources.  This produces a program called `temacs',
  39. also called a "bare impure Emacs".  It contains the Emacs Lisp
  40. interpreter and I/O routines, but not the editing commands.
  41.                                       Then, to create a working Emacs
  42. editor, issue the `temacs -l loadup' command.  This directs `temacs' to
  43. evaluate the Lisp files specified in the file `loadup.el'.  These files
  44. set up the normal Emacs editing environment, resulting in an Emacs
  45. which is still impure but no longer bare.
  46.                                       It takes a long time to load the
  47. standard Lisp files.  Luckily, you don't have to do this each time you
  48. run Emacs; `temacs' can dump out an executable program called `emacs'
  49. which has these files preloaded.  `emacs' starts more quickly because
  50. it does not need to load the files.  This is the program that is
  51. normally installed.
  52.                                       To create `emacs', use the
  53. command `temacs -batch -l loadup dump'.  The purpose of `-batch' here
  54. is to prevent `temacs' from trying to initialize any of its data on the
  55. terminal; this ensures that the tables of terminal information are
  56. empty in the dumped Emacs.
  57.                                       When the `emacs' executable is
  58. started, it automatically loads the user's `.emacs' file, or the
  59. default initialization file `default.el' if the user has none.  (*Note
  60. Starting Up::.)  With the `.emacs' file, you can produce a version of
  61. Emacs that suits you and is not the same as the version other people
  62. use.  With `default.el', you can customize Emacs for all the users at
  63. your site who don't choose to customize it for themselves.  (For further
  64. reflection: why is this different from the case of the barber who shaves
  65. every man who doesn't shave himself?)
  66.                                       On some systems, dumping does not
  67. work.  Then, you must start Emacs with the `temacs -l loadup' command
  68. each time you use it.  This takes a long time, but since you need to
  69. start Emacs once a day at most--and once a week or less frequently if
  70. you never log out--the extra time is not too severe a problem.
  71.                                       Before `emacs' is dumped, the
  72. documentation strings for primitive and preloaded functions (and
  73. variables) need to be found in the file where they are stored.  This is
  74. done by calling `Snarf-documentation' (*note Accessing
  75. Documentation::.).  These strings were moved out of `emacs' to make it
  76. smaller.  *Note Documentation Basics::.
  77.                                     - Function: dump-emacs TO-FILE
  78.                                              FROM-FILE
  79.                                         This function dumps the current
  80.                                         state of Emacs into an
  81.                                         executable file TO-FILE.  It
  82.                                         takes symbols from FROM-FILE
  83.                                         (this is normally the
  84.                                         executable file `temacs').
  85.                                         If you use this function in an
  86.                                         Emacs that was already dumped,
  87.                                         you must set
  88.                                         `command-line-processed' to
  89.                                         `nil' first for good results.
  90.                                         *Note Command Line Arguments::.
  91.                                     - Command: emacs-version
  92.                                         This function returns a string
  93.                                         describing the version of Emacs
  94.                                         that is running.  It is useful
  95.                                         to include this string in bug
  96.                                         reports.
  97.                                              (emacs-version)
  98.                                                => "GNU Emacs 18.36.1 of Fri Feb 27 1987 on slug
  99.                                                   (berkeley-unix)"
  100.                                         Called interactively, the
  101.                                         function prints the same
  102.                                         information in the echo area.
  103.                                     - Variable: emacs-build-time
  104.                                         The value of this variable is
  105.                                         the time at which Emacs was
  106.                                         built at the local site.
  107.                                              emacs-build-time
  108.                                                   => "Fri Feb 27 14:55:57 1987"
  109.                                     - Variable: emacs-version
  110.                                         The value of this variable is
  111.                                         the version of Emacs being run.
  112.                                         It is a string, e.g.
  113.                                         `"18.36.1"'.
  114. File: elisp,  Node: Pure Storage,  Next: Garbage Collection,  Prev: Building Emacs,  Up: GNU Emacs Internals
  115. Pure Storage
  116. ============
  117.                                       There are two types of storage in
  118. GNU Emacs Lisp for user-created Lisp objects: "normal storage" and
  119. "pure storage".  Normal storage is where all the new data which is
  120. created during an Emacs session is kept; see the following section for
  121. information on normal storage.  Pure storage is used for certain data
  122. in the preloaded standard Lisp files: data that should never change
  123. during actual use of Emacs.
  124.                                       Pure storage is allocated only
  125. while `temacs' is loading the standard preloaded Lisp libraries.  In
  126. the file `emacs', it is marked as read-only (on operating systems which
  127. permit this), so that the memory space can be shared by all the Emacs
  128. jobs running on the machine at once.  Pure storage is not expandable; a
  129. fixed amount is allocated when Emacs is compiled, and if that is not
  130. sufficient for the preloaded libraries, `temacs' crashes.  If that
  131. happens, you will have to increase the compilation parameter `PURESIZE'
  132. in the file `config.h'.  This normally won't happen unless you try to
  133. preload additional libraries or add features to the standard ones.
  134.                                     - Function: purecopy OBJECT
  135.                                         This function makes a copy of
  136.                                         OBJECT in pure storage and
  137.                                         returns it.  It copies strings
  138.                                         by simply making a new string
  139.                                         with the same characters in
  140.                                         pure storage.  It recursively
  141.                                         copies the contents of vectors
  142.                                         and cons cells.  It does not
  143.                                         make copies of symbols, or any
  144.                                         other objects, but just returns
  145.                                         them unchanged.  It signals an
  146.                                         error if asked to copy markers.
  147.                                         This function is used only
  148.                                         while Emacs is being built and
  149.                                         dumped; it is called only in
  150.                                         the file
  151.                                         `emacs/lisp/loaddefs.el'.
  152.                                     - Variable: pure-bytes-used
  153.                                         The value of this variable is
  154.                                         the number of bytes of pure
  155.                                         storage allocated so far.
  156.                                         Typically, in a dumped Emacs,
  157.                                         this number is very close to
  158.                                         the total amount of pure
  159.                                         storage available--if it were
  160.                                         not, we would preallocate less.
  161.                                     - Variable: purify-flag
  162.                                         This variable determines
  163.                                         whether `defun' should make a
  164.                                         copy of the function definition
  165.                                         in pure storage.  If it is
  166.                                         non-`nil', then the function
  167.                                         definition is copied into pure
  168.                                         storage.
  169.                                         This flag is `t' while loading
  170.                                         all of the basic functions for
  171.                                         building Emacs initially
  172.                                         (allowing those functions to be
  173.                                         sharable and non-collectible).
  174.                                         It is set to `nil' when Emacs
  175.                                         is saved out as `emacs'.  The
  176.                                         flag is set and reset in the C
  177.                                         sources.
  178.                                         You should not change this flag
  179.                                         in a running Emacs.
  180. File: elisp,  Node: Garbage Collection,  Next: Writing Emacs Primitives,  Prev: Pure Storage,  Up: GNU Emacs Internals
  181. Garbage Collection
  182. ==================
  183.                                       When a program creates a list or
  184. the user defines a new function (such as by loading a library), then
  185. that data is placed in normal storage.  If normal storage runs low,
  186. then Emacs asks the operating system to allocate more memory in blocks
  187. of 1k bytes.  Each block is used for one type of Lisp object, so
  188. symbols, cons cells, markers, etc. are segregated in distinct blocks in
  189. memory.  (Vectors, buffers and certain other editing types, which are
  190. fairly large, are allocated in individual blocks, one per object, while
  191. strings are packed into blocks of 8k bytes.)
  192.                                       It is quite common to use some
  193. storage for a while, then release it by, for example, killing a buffer
  194. or deleting the last pointer to an object.  Emacs provides a "garbage
  195. collector" to reclaim this abandoned storage.  (This name is
  196. traditional, but "garbage recycler" might be a more intuitive metaphor
  197. for this facility.)
  198.                                       The garbage collector operates by
  199. scanning all the objects that have been allocated and marking those
  200. that are still accessible to Lisp programs.  To begin with, all the
  201. symbols, their values and associated function definitions, and any data
  202. presently on the stack, are accessible.  Any objects which can be
  203. reached indirectly through other accessible objects are also accessible.
  204.                                       When this is finished, all
  205. inaccessible objects are garbage.  No matter what the Lisp program or
  206. the user does, it is impossible to refer to them, since there is no
  207. longer a way to reach them.  Their space might as well be reused, since
  208. no one will notice.  That is what the garbage collector arranges to do.
  209.                                       Unused cons cells are chained
  210. together onto a "free list" for future allocation; likewise for symbols
  211. and markers.  The accessible strings are compacted so they are
  212. contiguous in memory; then the rest of the space formerly occupied by
  213. strings is made available to the string creation functions.  Vectors,
  214. buffers, windows and other large objects are individually allocated and
  215. freed using `malloc'.
  216.                                         Common Lisp note: unlike other
  217.                                         Lisps, GNU Emacs Lisp does not
  218.                                         call the garbage collector when
  219.                                         the free list is empty.
  220.                                         Instead, it simply requests the
  221.                                         operating system to allocate
  222.                                         more storage, and processing
  223.                                         continues until
  224.                                         `gc-cons-threshold' bytes have
  225.                                         been used.
  226.                                         This means that you can make
  227.                                         sure that the garbage collector
  228.                                         will not run during a certain
  229.                                         portion of a Lisp program by
  230.                                         calling the garbage collector
  231.                                         explicitly just before it
  232.                                         (provided that portion of the
  233.                                         program does not use so much
  234.                                         space as to force a second
  235.                                         garbage collection).
  236.                                     - Command: garbage-collect
  237.                                         This command runs a garbage
  238.                                         collection, and returns
  239.                                         information on the amount of
  240.                                         space in use.  (Garbage
  241.                                         collection can also occur
  242.                                         spontaneously if you use more
  243.                                         than `gc-cons-threshold' bytes
  244.                                         of Lisp data since the previous
  245.                                         garbage collection.)
  246.                                         `garbage-collect' returns a
  247.                                         list containing the following
  248.                                         information:
  249.                                              ((USED-CONSES . FREE-CONSES)
  250.                                               (USED-SYMS . FREE-SYMS)
  251.                                               (USED-MARKERS . FREE-MARKERS)
  252.                                               USED-STRING-CHARS
  253.                                               USED-VECTOR-SLOTS
  254.                                               (USED-FLOATS . FREE-FLOATS))
  255.                                              
  256.                                              (garbage-collect)
  257.                                                   => ((3435 . 2332) (1688 . 0) (57 . 417) 24510 3839 (4 . 1))
  258.                                         Here is a table explaining each
  259.                                         element:
  260.                                        USED-CONSES
  261.                                              The number of cons cells
  262.                                              in use.
  263.                                        FREE-CONSES
  264.                                              The number of cons cells
  265.                                              for which space has been
  266.                                              obtained from the
  267.                                              operating system, but that
  268.                                              are not currently being
  269.                                              used.
  270.                                        USED-SYMS
  271.                                              The number of symbols in
  272.                                              use.
  273.                                        FREE-SYMS
  274.                                              The number of symbols for
  275.                                              which space has been
  276.                                              obtained from the
  277.                                              operating system, but that
  278.                                              are not currently being
  279.                                              used.
  280.                                        USED-MARKERS
  281.                                              The number of markers in
  282.                                              use.
  283.                                        FREE-MARKERS
  284.                                              The number of markers for
  285.                                              which space has been
  286.                                              obtained from the
  287.                                              operating system, but that
  288.                                              are not currently being
  289.                                              used.
  290.                                        USED-STRING-CHARS
  291.                                              The total size of all
  292.                                              strings, in characters.
  293.                                        USED-VECTOR-SLOTS
  294.                                              The total number of
  295.                                              elements of existing
  296.                                              vectors.
  297.                                        USED-FLOATS
  298.                                              The number of floats in
  299.                                              use.
  300.                                        FREE-FLOATS
  301.                                              The number of floats for
  302.                                              which space has been
  303.                                              obtained from the
  304.                                              operating system, but that
  305.                                              are not currently being
  306.                                              used.
  307.                                     - User Option: gc-cons-threshold
  308.                                         The value of this variable is
  309.                                         the number of bytes of storage
  310.                                         that must be allocated for Lisp
  311.                                         objects after one garbage
  312.                                         collection in order to request
  313.                                         another garbage collection.  A
  314.                                         cons cell counts as eight bytes,
  315.                                         a string as one byte per
  316.                                         character plus a few bytes of
  317.                                         overhead, and so on.  (Space
  318.                                         allocated to the contents of
  319.                                         buffers does not count.)  Note
  320.                                         that the new garbage collection
  321.                                         does not happen immediately
  322.                                         when the threshold is
  323.                                         exhausted, but only the next
  324.                                         time the Lisp evaluator is
  325.                                         called.
  326.                                         The initial threshold value is
  327.                                         100,000.  If you specify a
  328.                                         larger value, garbage
  329.                                         collection will happen less
  330.                                         often.  This reduces the amount
  331.                                         of time spent garbage
  332.                                         collecting, but increases total
  333.                                         memory use.  You may want to do
  334.                                         this when running a program
  335.                                         which creates lots of Lisp data.
  336.                                         You can make collections more
  337.                                         frequent by specifying a
  338.                                         smaller value, down to 10,000.
  339.                                         A value less than 10,000 will
  340.                                         remain in effect only until the
  341.                                         subsequent garbage collection,
  342.                                         at which time `garbage-collect'
  343.                                         will set the threshold back to
  344.                                         10,000.
  345.                                     - Function: memory-limit
  346.                                         This function returns the
  347.                                         address of the last byte Emacs
  348.                                         has allocated, divided by 1024.
  349.                                         We divide the value by 1024 to
  350.                                         make sure it fits in a Lisp
  351.                                         integer.
  352.                                         You can use this to get a
  353.                                         general idea of how your
  354.                                         actions affect the memory usage.
  355. File: elisp,  Node: Writing Emacs Primitives,  Next: Object Internals,  Prev: Garbage Collection,  Up: GNU Emacs Internals
  356. Writing Emacs Primitives
  357. ========================
  358.                                       Lisp primitives are Lisp
  359. functions implemented in C.  The details of interfacing the C function
  360. so that Lisp can call it are handled by a few C macros.  The only way
  361. to really understand how to write new C code is to read the source, but
  362. we can explain some things here.
  363.                                       An example of a special form is
  364. the definition of `or', from `eval.c'.  (An ordinary function would
  365. have the same general appearance.)
  366.                                         DEFUN ("or", For, Sor, 0, UNEVALLED, 0,
  367.                                           "Eval args until one of them yields non-NIL, then return that value.\n\
  368.                                         The remaining args are not evalled at all.\n\
  369.                                         If all args return NIL, return NIL.")
  370.                                           (args)
  371.                                              Lisp_Object args;
  372.                                         {
  373.                                           register Lisp_Object val;
  374.                                           Lisp_Object args_left;
  375.                                           struct gcpro gcpro1;
  376.                                         if (NULL(args))
  377.                                             return Qnil;
  378.                                         
  379.                                           args_left = args;
  380.                                           GCPRO1 (args_left);
  381.                                         do
  382.                                             {
  383.                                               val = Feval (Fcar (args_left));
  384.                                               if (!NULL (val))
  385.                                                 break;
  386.                                               args_left = Fcdr (args_left);
  387.                                             }
  388.                                           while (!NULL(args_left));
  389.                                         UNGCPRO;
  390.                                           return val;
  391.                                         }
  392.                                       Let's start with a precise
  393. explanation of the arguments to the `DEFUN' macro.  Here are the
  394. general names for them:
  395.                                         DEFUN (LNAME, FNAME, SNAME, MIN, MAX, INTERACTIVE, DOC)
  396.                                   LNAME
  397.                                         This is the name of the Lisp
  398.                                         symbol to define with this
  399.                                         function; in the example above,
  400.                                         it is `or'.
  401.                                   FNAME
  402.                                         This is the C function name for
  403.                                         this function.  This is the
  404.                                         name that is used in C code for
  405.                                         calling the function.  The name
  406.                                         is, by convention, `F'
  407.                                         prepended to the Lisp name,
  408.                                         with all dashes (`-') in the
  409.                                         Lisp name changed to
  410.                                         underscores.  Thus, to call this
  411.                                         function from C code, call
  412.                                         `For'.  Remember that the
  413.                                         arguments must be of type
  414.                                         `Lisp_Object'; various macros
  415.                                         and functions for creating
  416.                                         values of type `Lisp_Object'
  417.                                         are declared in the file
  418.                                         `lisp.h'.
  419.                                   SNAME
  420.                                         This is a C variable name to
  421.                                         use for a structure that holds
  422.                                         the data for the subr object
  423.                                         that represents the function in
  424.                                         Lisp.  This structure conveys
  425.                                         the Lisp symbol name to the
  426.                                         initialization routine that will
  427.                                         create the symbol and store the
  428.                                         subr object as its definition.
  429.                                         By convention, this name is
  430.                                         always FNAME with `F' replaced
  431.                                         with `S'.
  432.                                   MIN
  433.                                         This is the minimum number of
  434.                                         arguments that the function
  435.                                         requires.  For `or', no
  436.                                         arguments are required.
  437.                                   MAX
  438.                                         This is the maximum number of
  439.                                         arguments that the function
  440.                                         accepts.  Alternatively, it can
  441.                                         be `UNEVALLED', indicating a
  442.                                         special form that receives
  443.                                         unevaluated arguments.  A
  444.                                         function with the equivalent of
  445.                                         an `&rest' argument would have
  446.                                         `MANY' in this position.  Both
  447.                                         `UNEVALLED' and `MANY' are
  448.                                         macros.  This argument must be
  449.                                         one of these macros or a number
  450.                                         at least as large as MIN.  It
  451.                                         may not be greater than six.
  452.                                   INTERACTIVE
  453.                                         This is an interactive
  454.                                         specification, a string such as
  455.                                         might be used as the argument
  456.                                         of `interactive' in a Lisp
  457.                                         function.  In the case of `or',
  458.                                         it is 0 (a null pointer),
  459.                                         indicating that `or' cannot be
  460.                                         called interactively.  A value
  461.                                         of `""' indicates an interactive
  462.                                         function taking no arguments.
  463.                                   DOC
  464.                                         This is the documentation
  465.                                         string.  It is written just
  466.                                         like a documentation string for
  467.                                         a function defined in Lisp,
  468.                                         except you must write `\n\' at
  469.                                         the end of each line.  In
  470.                                         particular, the first line
  471.                                         should be a single sentence.
  472.                                       After the call to the `DEFUN'
  473. macro, you must write the list of argument names that every C function
  474. must have, followed by ordinary C declarations for them.  Normally, all
  475. the arguments must be declared as `Lisp_Object'.  If the function has
  476. no upper limit on the number of arguments in Lisp, then in C it
  477. receives two arguments: the number of Lisp arguments, and the address
  478. of a block containing their values.  These have types `int' and
  479. `Lisp_Object *'.
  480.                                       Within the function `For' itself,
  481. note the use of the macros `GCPRO1' and `UNGCPRO'.  `GCPRO1' is used to
  482. "protect" a variable from garbage collection--to inform the garbage
  483. collector that it must look in that variable and regard its contents as
  484. an accessible object.  This is necessary whenever you call `Feval' or
  485. anything that can directly or indirectly call `Feval'.  At such a time,
  486. any Lisp object that you intend to refer to again must be protected
  487. somehow.  `UNGCPRO' cancels the protection of the variables that are
  488. protected in the current function.  It is necessary to do this
  489. explicitly.
  490.                                       For most data types, it suffices
  491. to know that one pointer to the object is protected; as long as the
  492. object is not recycled, all pointers to it remain valid.  This is not
  493. so for strings, because the garbage collector can move them.  When a
  494. string is moved, any pointers to it that the garbage collector does not
  495. know about will not be properly relocated.  Therefore, all pointers to
  496. strings must be protected across any point where garbage collection may
  497. be possible.
  498.                                       The macro `GCPRO1' protects just
  499. one local variable.  If you want to protect two, use `GCPRO2' instead;
  500. repeating `GCPRO1' will not work.  There are also `GCPRO3' and `GCPRO4'.
  501.                                       In addition to using these
  502. macros, you must declare the local variables such as `gcpro1' which
  503. they implicitly use.  If you protect two variables, with `GCPRO2', you
  504. must declare `gcpro1' and `gcpro2', as it uses them both.  Alas, we
  505. can't explain all the tricky details here.
  506.                                       Defining the C function is not
  507. enough; you must also create the Lisp symbol for the primitive and
  508. store a suitable subr object in its function cell.  This is done by
  509. adding code to an initialization routine.  The code looks like this:
  510.                                         defsubr (&SUBR-STRUCTURE-NAME);
  511.                                    SUBR-STRUCTURE-NAME is the name you
  512. used as the third argument to `DEFUN'.
  513.                                       If you are adding a primitive to
  514. a file that already has Lisp primitives defined in it, find the
  515. function (near the end of the file) named `syms_of_SOMETHING', and add
  516. that function call to it.  If the file doesn't have this function, or
  517. if you create a new file, add to it a `syms_of_FILENAME' (e.g.,
  518. `syms_of_myfile').  Then find the spot in `emacs.c' where all of these
  519. functions are called, and add a call to `syms_of_FILENAME' there.
  520.                                       This function `syms_of_FILENAME'
  521. is also the place to define any C variables which are to be visible as
  522. Lisp variables.  `DEFVAR_LISP' is used to make a C variable of type
  523. `Lisp_Object' visible in Lisp.  `DEFVAR_INT' is used to make a C
  524. variable of type `int' visible in Lisp with a value that is an integer.
  525.                                       Here is another function, with
  526. more complicated arguments.  This comes from the code for the X Window
  527. System, and it demonstrates the use of macros and functions to
  528. manipulate Lisp objects.
  529.                                         DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
  530.                                           Scoordinates_in_window_p, 2, 2,
  531.                                           "xSpecify coordinate pair: \nXExpression which evals to window: ",
  532.                                           "Return non-nil if POSITIONS is in WINDOW.\n\
  533.                                           \(POSITIONS is a list, (SCREEN-X SCREEN-Y)\)\n\
  534.                                         Returned value is list of positions expressed\n\
  535.                                           relative to window upper left corner.")
  536.                                           (coordinate, window)
  537.                                              register Lisp_Object coordinate, window;
  538.                                         {
  539.                                           register Lisp_Object xcoord, ycoord;
  540.                                         if (!CONSP (coordinate)) wrong_type_argument (Qlistp, coordinate);
  541.                                           CHECK_WINDOW (window, 2);
  542.                                           xcoord = Fcar (coordinate);
  543.                                           ycoord = Fcar (Fcdr (coordinate));
  544.                                           CHECK_NUMBER (xcoord, 0);
  545.                                           CHECK_NUMBER (ycoord, 1);
  546.                                         if ((XINT (xcoord) < XINT (XWINDOW (window)->left))
  547.                                               || (XINT (xcoord) >= (XINT (XWINDOW (window)->left)
  548.                                                                     + XINT (XWINDOW (window)->width))))
  549.                                             {
  550.                                               return Qnil;
  551.                                             }
  552.                                           XFASTINT (xcoord) -= XFASTINT (XWINDOW (window)->left);
  553.                                         if (XINT (ycoord) == (screen_height - 1))
  554.                                             return Qnil;
  555.                                         if ((XINT (ycoord) < XINT (XWINDOW (window)->top))
  556.                                               || (XINT (ycoord) >= (XINT (XWINDOW (window)->top)
  557.                                                                     + XINT (XWINDOW (window)->height)) - 1))
  558.                                             {
  559.                                               return Qnil;
  560.                                             }
  561.                                         XFASTINT (ycoord) -= XFASTINT (XWINDOW (window)->top);
  562.                                           return (Fcons (xcoord, Fcons (ycoord, Qnil)));
  563.                                         }
  564.                                       Note that you cannot directly
  565. call functions defined in Lisp as, for example, the primitive function
  566. `Fcons' is called above.  You must create the appropriate Lisp form,
  567. protect everything from garbage collection, and `Feval' the form, as
  568. was done in `For' above.
  569.                                       `eval.c' is a very good file to
  570. look through for examples; `lisp.h' contains the definitions for some
  571. important macros and functions.
  572. File: elisp,  Node: Object Internals,  Prev: Writing Emacs Primitives,  Up: GNU Emacs Internals
  573. Object Internals
  574. ================
  575.                                       GNU Emacs Lisp manipulates many
  576. different types of data.  The actual data are stored in a heap and the
  577. only access that programs have to it is through pointers.  Pointers are
  578. thirty-two bits wide in most implementations.  Depending on the
  579. operating system and type of machine for which you compile Emacs,
  580. twenty-four to twenty-six bits are used to address the object, and the
  581. remaining six to eight bits are used for a tag that identifies the
  582. object's type.
  583.                                       Because all access to data is
  584. through tagged pointers, it is always possible to determine the type of
  585. any object.  This allows variables to be untyped, and the values
  586. assigned to them to be changed without regard to type.  Function
  587. arguments also can be of any type; if you want a function to accept
  588. only a certain type of argument, you must check the type explicitly
  589. using a suitable predicate (*note Type Predicates::.).
  590.                                    * Menu:
  591.                                    
  592.                                    * Buffer Internals::    Components of a buffer structure.
  593.                                    * Window Internals::    Components of a window structure.
  594.                                    * Process Internals::   Components of a process structure.
  595. File: elisp,  Node: Buffer Internals,  Next: Window Internals,  Prev: Object Internals,  Up: Object Internals
  596. Buffer Internals
  597. ----------------
  598.                                       Buffers contain fields not
  599. directly accessible by the Lisp programmer.  We describe them here,
  600. naming them by the names used in the C code.  Many are accessible
  601. indirectly in Lisp programs via Lisp primitives.
  602.                                   `name'
  603.                                         The buffer name is a string
  604.                                         which names the buffer.  It is
  605.                                         guaranteed to be unique.  *Note
  606.                                         Buffer Names::.
  607.                                   `save_modified'
  608.                                         This field contains the time
  609.                                         when the buffer was last saved,
  610.                                         as an integer.  *Note Buffer
  611.                                         Modification::.
  612.                                   `modtime'
  613.                                         This field contains the
  614.                                         modification time of the
  615.                                         visited file.  It is set when
  616.                                         the file is written or read.
  617.                                         Every time the buffer is written
  618.                                         to the file, this field is
  619.                                         compared to the modification
  620.                                         time of the file.  *Note Buffer
  621.                                         Modification::.
  622.                                   `auto_save_modified'
  623.                                         This field contains the time
  624.                                         when the buffer was last
  625.                                         auto-saved.
  626.                                   `last_window_start'
  627.                                         This field contains the
  628.                                         `window-start' position in the
  629.                                         buffer as of the last time the
  630.                                         buffer was displayed in a
  631.                                         window.
  632.                                   `undodata'
  633.                                         This field points to the
  634.                                         buffer's undo stack.  *Note
  635.                                         Undo::.
  636.                                   `syntax_table_v'
  637.                                         This field contains the syntax
  638.                                         table for the buffer.  *Note
  639.                                         Syntax Tables::.
  640.                                   `downcase_table'
  641.                                         This field contains the
  642.                                         conversion table for converting
  643.                                         text to lower case.  *Note Case
  644.                                         Table::.
  645.                                   `upcase_table'
  646.                                         This field contains the
  647.                                         conversion table for converting
  648.                                         text to upper case.  *Note Case
  649.                                         Table::.
  650.                                   `case_canon_table'
  651.                                         This field contains the
  652.                                         conversion table for
  653.                                         canonicalizing text for
  654.                                         case-folding search.  *Note
  655.                                         Case Table::.
  656.                                   `case_eqv_table'
  657.                                         This field contains the
  658.                                         equivalence table for
  659.                                         case-folding search.  *Note
  660.                                         Case Table::.
  661.                                   `display_table'
  662.                                         This field contains the
  663.                                         buffer's display table, or
  664.                                         `nil' if it doesn't have one.
  665.                                         *Note Display Tables::.
  666.                                   `markers'
  667.                                         This field contains the chain
  668.                                         of all markers that point into
  669.                                         the buffer.  At each deletion
  670.                                         or motion of the buffer gap,
  671.                                         all of these markers must be
  672.                                         checked and perhaps updated.
  673.                                         *Note Markers::.
  674.                                   `backed_up'
  675.                                         This field is a flag which
  676.                                         tells whether a backup file has
  677.                                         been made for the visited file
  678.                                         of this buffer.
  679.                                   `mark'
  680.                                         This field contains the mark
  681.                                         for the buffer.  The mark is a
  682.                                         marker, hence it is also
  683.                                         included on the list `markers'.
  684.                                         *Note The Mark::.
  685.                                   `local_var_alist'
  686.                                         This field contains the
  687.                                         association list containing all
  688.                                         of the variables local in this
  689.                                         buffer, and their values.  The
  690.                                         function
  691.                                         `buffer-local-variables'
  692.                                         returns a copy of this list.
  693.                                         *Note Buffer-Local Variables::.
  694.                                   `mode_line_format'
  695.                                         This field contains a Lisp
  696.                                         object which controls how to
  697.                                         display the mode line for this
  698.                                         buffer.  *Note Mode Line
  699.                                         Format::.
  700. File: elisp,  Node: Window Internals,  Next: Process Internals,  Prev: Buffer Internals,  Up: Object Internals
  701. Window Internals
  702. ----------------
  703.                                       Windows have the following
  704. accessible fields:
  705.                                   `frame'
  706.                                         The frame that this window is
  707.                                         on.
  708.                                   `mini_p'
  709.                                         Non-`nil' if this window is a
  710.                                         minibuffer window.
  711.                                   `height'
  712.                                         The height of the window,
  713.                                         measured in lines.
  714.                                   `width'
  715.                                         The width of the window,
  716.                                         measured in columns.
  717.                                   `buffer'
  718.                                         The buffer which the window is
  719.                                         displaying.  This may change
  720.                                         often during the life of the
  721.                                         window.
  722.                                   `dedicated'
  723.                                         Non-`nil' if this window is
  724.                                         dedicated to its buffer.
  725.                                   `start'
  726.                                         The position in the buffer
  727.                                         which is the first character to
  728.                                         be displayed in the window.
  729.                                   `pointm'
  730.                                         This is the value of point in
  731.                                         the current buffer when this
  732.                                         window is selected; when it is
  733.                                         not selected, it retains its
  734.                                         previous value.
  735.                                   `left'
  736.                                         This is the left-hand edge of
  737.                                         the window, measured in
  738.                                         columns.  (The leftmost column
  739.                                         on the screen is column 0.)
  740.                                   `top'
  741.                                         This is the top edge of the
  742.                                         window, measured in lines.
  743.                                         (The top line on the screen is
  744.                                         line 0.)
  745.                                   `next'
  746.                                         This is the window that is the
  747.                                         next in the chain of siblings.
  748.                                   `prev'
  749.                                         This is the window that is the
  750.                                         previous in the chain of
  751.                                         siblings.
  752.                                   `force_start'
  753.                                         This is a flag which, if
  754.                                         non-`nil', says that the window
  755.                                         has been scrolled explicitly by
  756.                                         the Lisp program.  At the next
  757.                                         redisplay, if point is off the
  758.                                         screen, instead of scrolling
  759.                                         the window to show the text
  760.                                         around point, point will be
  761.                                         moved to a location that is on
  762.                                         the screen.
  763.                                   `hscroll'
  764.                                         This is the number of columns
  765.                                         that the display in the window
  766.                                         is scrolled horizontally to the
  767.                                         left.  Normally, this is 0.
  768.                                   `use_time'
  769.                                         This is the last time that the
  770.                                         window was selected.  The
  771.                                         function `get-lru-window' uses
  772.                                         this field.
  773.                                   `display_table'
  774.                                         The window's display table, or
  775.                                         `nil' if none is specified for
  776.                                         it.
  777.